window.addEvent('domready', function(){
	/*add team*/
	$('addteam').onclick = function(event){      
	    $('action').value = 'add';
	    /*if($('name').value == ''){
	    	alert('Please fill the Name field!');
	    	return false;
	    }    */
	    $('wteam').submit();
	};
	
	$('qName').addEvent('keydown', function(event){
	    event = new Event(event);    
	    if (event.key == 'enter') {
	        $('action').value = 'info';
	    	$('wteam').submit();
	    }
	});
});

/*submit a query form*/
function queryList(){	
    $('action').value = 'info';
    $('wteam').submit();
}

/*delete team*/
function delTeam(teamId, teamName){
	if(window.confirm('Are you sure to delete team: '+teamName)){
		$('action').value = 'del';
		$('teamid').value = teamId;		
		$('wteam').submit();
		
	}else{
		return false;
	}
}

/*edit team info*/
function editTeam(teamId){
	var request_uri = '/wizard/teamedit?ajax=1&t='+(new Date()).getTime();	
	PopBox.pop('loading ...', {loading:true});
	close_redir_url = "/wizard/team";
	new Ajax(request_uri, {
		method: 'get',
		evalScripts : true,
		data: Object.toQueryString({			
			teamid: teamId
		}),
		onComplete: function(){	
			PopBox.pop(this.response.text);
		}
	}).request();
}
